#include <iostream>
#include <vector>
#include <set>
using namespace std;

// 100.00 %
class Solution
{
  public:
	vector<int> intersection(vector<int> &nums1, vector<int> &nums2)
	{
		set<int> mySet(nums1.begin(), nums1.end());
		set<int> re;
		for (int i = 0; i < nums2.size(); i++)
		{
			if (mySet.find(nums2[i]) != mySet.end())
			{
				re.insert(nums2[i]);
			}
		}
		vector<int> myVec1(re.begin(), re.end());
		return myVec1;
	}
};

int main()
{
	int arr1[4] = {1, 2, 2, 1};
	int arr2[2] = {2, 2};
	vector<int> myVec1(arr1, arr1 + 3);
	vector<int> myVec2(arr2, arr2 + 3);
	vector<int> re = Solution().intersection(myVec1, myVec2);
	for (int i = 0; i < re.size() - 1; i++)
	{
		cout << re[i] << " ";
	}
	cout << re[re.size() - 1] << endl;
	return 0;
}
